package com.liruo.learn.spring.mvc.controller.valid;

import com.liruo.learn.spring.mvc.controller.valid.group.Add;
import com.liruo.learn.spring.mvc.controller.valid.group.Update;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;

/**
 * @Author:liruo
 * @Date:2023-05-08-22:59:54
 * @Desc
 */
//@GroupSequence 一个组校验失败, 就立刻失败(必须加上本类--Default组) 等同于@Validated({Add.class, Default.class})
//@GroupSequence({Add.class, ValidBean.class})
@Data
public class ValidBean {
    /**
     * @XXX.List 用于不同分组的错误信息
     */
    @NotEmpty.List({
            @NotEmpty(message = "name add不为null", groups = Add.class),
            @NotEmpty(message = "name update不为null", groups = Update.class)
    })
    private String name;
    @Max(value = 150, message = "必须在18-150")
    @Min(value = 1, message = "必须在18-150")
    private Integer age;
}
